<%--
  Created by IntelliJ IDEA.
  User: teacher
  Date: 2023/10/23
  Time: 17:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>四大作用域</title>
</head>
<body>
<%
    // 模拟数据存储过程
    pageContext.setAttribute("msg","Hello pageContext");
    request.setAttribute("msg","Hello request");
    session.setAttribute("msg","Hello session");
    application.setAttribute("msg","Hello application");
%>
<h1>当前页面</h1>
pageContext:<%=pageContext.getAttribute("msg")%><br>
request:<%=request.getAttribute("msg")%><br>
session:<%=session.getAttribute("msg")%><br>
application:<%=application.getAttribute("msg")%><br>
<%
    // 转发到另一个页面
    // 此时不再是同一个页面,但是共享请求
    // request.getRequestDispatcher("/jsp/scope2.jsp").forward(request,response);
    // 重定向到另一个页面
    // 此时不再是同一个请求
    response.sendRedirect(request.getContextPath()+"/jsp/scope2.jsp");
%>
</body>
</html>
